// JavaScript Document

function validate(){
	
	

var days=document.getElementById('sltDay');
var subgr=document.getElementById('sltSubgr');
var start=document.getElementById('sltStart');
var end=document.getElementById('sltEnd');
var empno=document.getElementById('txtEmpno');


             if(madeSelection(subgr,"Select the Subject code")){
				   if(madeSelection(days,"Select the Day")){
                   if(madeSelection(start,"Select the Start Time")){
                          if(madeSelection(end,"Select the End Time")){
						              if(notEmpty(empno,"Emp No cannot be empty")){
								                if(isNumeric(empno,"should be numeric ")){
                                                     if(emptyLengthrestrict(empno, 4, 4,"Emp No length should be 4")){
                                                          
														  
                                                        loadXMLDoc()

													}
												  return false;
												  }
												
									       return false;     
	                                      }
		                         return false;
								 }
		                        return false;
								}
	                      return false;
						  } 
                     return false;
					 }
                  return false;
				  }


		function clearx(){

	
	 document.getElementById("myForm").reset(); 
     document.getElementById("ajaxDiv").innerHTML="";
     document.getElementById("ajaxDiv1").innerHTML="";
}

function loadXMLDoc()
{


if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
		
    document.getElementById("ajaxDiv").innerHTML=xmlhttp.responseText;
	document.getElementById("myForm").reset(); 
	
    }
  }
       
	    var dayss=document.getElementById('sltDay').value;
        var subgrs=document.getElementById('sltSubgr').value;
        var starts=document.getElementById('sltStart').value;
        var ends=document.getElementById('sltEnd').value;
        var empnos=document.getElementById('txtEmpno').value;
		var classs=document.getElementById('txtCno').value;
          
		  
	var queryString ="?subgr=" + subgrs +"&days="+dayss+ "&start=" + starts +"&end="+ends+ "&empno=" +empnos+"&class="+classs ;
	
	
	
xmlhttp.open("GET","../logic/add/schedule_add.php"+queryString ,true);
xmlhttp.send();
}
	
	
	
	function checkempno(){

var empno=document.getElementById('txtEmpno');
if(notEmpty(empno,"Emp No cannot be empty")){

 if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
   xmlhttp=new XMLHttpRequest();
    }
  else
   {// code for IE6, IE5
 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
     }
    xmlhttp.onreadystatechange=function()
     {
 if (xmlhttp.readyState==4 && xmlhttp.status==200)
  {
									//document.getElementById("ajaxDiv").innerHTML=xmlhttp.responseText; 
									 
   var x=xmlhttp.responseText;
if(x=="false"){
									
  document.getElementById("ajaxDiv1").innerHTML="Invalid Employee No";
  document.getElementById('txtEmpno').value="";
	}else{
  document.getElementById("ajaxDiv1").innerHTML=x; 
									
			}
			}
            }
								
  var y=document.getElementById('txtEmpno').value;
  var queryString ="?empno=" + y;
  xmlhttp.open("GET","../logic/load/check_emp.php"+queryString,true);
  xmlhttp.send();	  
	
	
}
}
	

